package com.lzj.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.DecimalFormat;

/**
 * <p>
 *
 * </p>
 *
 * @autor:lzj
 * @date:2021/12/8
 */
public class TotalPriceServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String count = req.getParameter("count");
        String price = req.getParameter("price");


        DecimalFormat df=new DecimalFormat("0.00");
        double sum = Integer.valueOf(count)*Double.valueOf(price);
        resp.getWriter().print(df.format(sum));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
